function showText( id ) { 
  document.getElementById(id).style.display = 'block'; 
} 
function hideText( id ) { 
  document.getElementById(id).style.display = 'none'; 
} 
function showXs(button)
{
  button.style.display = 'none';
  var c=document.getElementById("stats");
  var e=c.getElementsByTagName("a");
  for(var i=0;i<e.length;i++){ if (e[i].className == 'hidden') e[i].className = 'action';}
}

function addtext(textleft,textright) {
    var field=document.editingForm.definition;
    field.focus();
    if (document.selection) { //IE support
        var sel = document.selection.createRange();
        sel.text = textleft + sel.text + textright;
    }
    else if (field.selectionStart || field.selectionStart == '0') { //MOZILLA/NETSCAPE support
        var startPos = field.selectionStart;
        var endPos = field.selectionEnd;
        field.value = field.value.substring(0, startPos) + textleft
            + field.value.substring(startPos, endPos)
            + textright + field.value.substring(endPos, field.value.length);
        field.selectionEnd = endPos + textleft.length;
        field.selectionStart = startPos + textleft.length;
    } else {
        field.value += textleft + textright;
    }
}

function blockKey(event)
{
  if(event.keyCode==9) {
    addtext('   ','');
    if (event.preventDefault) event.preventDefault(); else event.returnValue = false;
  }  
}

function forceHTTPS()
{
  var loc=String(document.location);
  var newloc=loc.replace(/^[a-z]*:/,'https:').replace(/:[0-9]+[/]/,'/');
  if (newloc!=loc)
    document.location=newloc;
}

function getHTTPPath(port)
{ var txt='http://$1';
	if (port!=80) txt+=':'+port;
	return String(document.location).replace(/^[^/]*[/]+([^/]*)[/].*$/i,txt+'/');
}
function nonSecureLink(port)
{ var txt='http://$1';
	if (port!=80) txt+=':'+port;
	txt+='/$2';
	if (document.location.href.substring(0,6)=='https:') 
		document.write('<a href="'+
			(String(document.location).replace(/^[^/]*[/]+([^/]*)[/](.*)$/i,txt))+
			'" class="action">Non-secure</a>'
		);
}

function rename(me)
{
	val=prompt("Type new name","");
	if (val!=null && val!="")
	{ me.href=me.href+"&newname="+val;
		return true;
	}
	return false; 
}

function attach(me, resName)
{
	val=prompt("Type attachment name (including extension)",resName+'.zip');
	if (val!=null && val!="")
	{ me.href=me.href+"&name="+val;
		return true;
	}
	return false; 
}

sfHover = function() 
{
    var sfEls = document.getElementById("nav");
		if (sfEls!=null)
		{
				sfEls=sfEls.getElementsByTagName("LI"); 
		    for (var i=0; i<sfEls.length; i++) {
		         sfEls[i].onmouseover=function() { 
		            this.className+=" sfhover";
		         } 
		        sfEls[i].onmouseout=function() {
		            this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		         }
	     } 
		}
} 
if (window.attachEvent) window.attachEvent("onload", sfHover);

function returnToParent(mylink)
{
	window.opener.focus();
	window.opener.location.href=mylink.href;
	window.close();
	return false;
}

function popupSelector(a)
{
	window.open(a.href.replace("action.tsp?","selector.tsp?"), "Select", 'width=600,height=400,scrollbars=yes');
	return false;
}

function stayInSelector(a)
{
	a.href=a.href.replace("action.tsp?","selector.tsp?");
	return true;
}

function popupRemover(a)
{
	window.open(a.href, 'Remove', 'width=600,height=400,scrollbars=yes');
	return false;
}
